﻿Imports DAL
Imports Microsoft.Reporting.WinForms

Public Class FrmRapports
    Private repDataSource As Microsoft.Reporting.WinForms.ReportDataSource
    Private BindingSource1 As New BindingSource

    'Affichage du rapport choisi
    Public Sub SetRapport(ByVal ReportName As String, ByVal values As IEnumerable, Optional ByVal DataSetName As String = "DataSet1")
        Dim rptSource1 As New Microsoft.Reporting.WinForms.ReportDataSource
        rptSource1.Name = DataSetName
        rptSource1.Value = BindingSource1
        Me.ReportViewer1.LocalReport.DataSources.Add(rptSource1)
        Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "CarpeDiemHoraire." + ReportName
        Me.BindingSource1.DataSource = values
        Me.ReportViewer1.RefreshReport()

    End Sub

    'insertion des paramètres
    Public Sub SetParametre(ByVal params() As ReportParameter)
        Me.ReportViewer1.LocalReport.SetParameters(params)
        Me.ReportViewer1.RefreshReport()
    End Sub

    'Création de paramètres
    Public Function CreerParametre(ByVal name As String, ByVal value As Object) As ReportParameter
        Dim tempParam As New ReportParameter()
        tempParam.Name = name
        tempParam.Values.Add(value)
        Return tempParam
    End Function
End Class